package com.smh.Util;

import java.util.Random;

public class CodeUtil {
    private CodeUtil() {
    }

    public static String getCode() {
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            sb.append((char) (i + 'a'));
            sb.append((char) (i + 'A'));
        }
        char[] arr = sb.toString().toCharArray();

        StringBuilder sb2 = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            sb2.append(arr[random.nextInt(52)]);
        }
        sb2.append(random.nextInt(10));
        char[] arr2 = sb2.toString().toCharArray();
        int index = random.nextInt(4);
        char c = arr2[index];
        arr2[index] = arr2[4];
        arr2[4] = c;

        return new String(arr2);
    }
}
